package cn.jinbyte.starter.captcha.exception;

import cn.jinbyte.core.exception.BussException;
import cn.jinbyte.core.model.ApiCode;

/**
 * 验证码异常
 */
public class CaptchaException extends BussException {
    private CaptchaException(ApiCode apiCode) {
        super(apiCode);
    }

    public static void throwIfInvalid(boolean invalid) {
        if (invalid) {
            throw new CaptchaException(ApiCode.BE_CAPTCHA_INVALID);
        }
    }

    public static void throwIfExpired(boolean expired) {
        if (expired) {
            throw new CaptchaException(ApiCode.BE_CAPTCHA_EXPIRED);
        }
    }

    public static void throwIfError(boolean error) {
        if (error) {
            throw new CaptchaException(ApiCode.BE_CAPTCHA_ERROR);
        }
    }
}
